SET AUTOCOMMIT=0;
SET AUTOCOMMIT=1;
select @@autocommit;

INSERT INTO s_test VALUES (4,'ww',10);

-- 11
INSERT INTO s_test(name,age) VALUES ('我是老大，123123',10);

-- 回滚 
rollback

DELETE 
FROM s_test
WHERE id = 5;

alter table s_test add phone2 varchar(20);

SELECT * FROM s_test;
commit;


-- 查看数据库默认隔离级别
show variables like '%isolation%';


-- 设置为读已提交
set session transaction isolation level READ COMMITTED;
-- 删除表
drop table if exists t_account;
-- 创建账户表并插入数据
create table t_account(
id int(11) primary key auto_increment,
name varchar(20) not null,
balance decimal(10,2) default 0
);
insert into t_account(name,balance) values
('zs',2000.5),
('ls',3020.5);
-- 查询账户信息
select * from t_account;

COMMIT;
-- 1.开启事务1
begin;
-- 5.查询账户信息
select * from t_account;

select * from t_account;


create table dept(
id int primary key,
name varchar(20)
);
insert into dept values(1,'java'),(2,'bigdata'),(3,'web');
create table emp(
id int primary key,
name varchar(20),
salary double,
dept_id int,
foreign key(dept_id) references dept(id)
);
insert into emp values(1,'lisi',3000,1),(2,'wangwu',3200,1);
insert into emp(id,name,salary) values(5,'zhuqi',3500);
insert into emp values(3,'zhansan',2800,1),(4,'zhaoliu',900,2);



create or replace view v_emp(id,username)
as
select id,name
from emp;

desc emp;
select * from emp;
-- 查看视图结构
desc v_emp;
select * from v_emp;

create view v_emp1
as
select id,name,salary,salary*30
from emp;


create view v_emp_dept
as
select concat(e.name,'(',d.name,')') as
username,e.salary,e.dept_id,d.name dept_name
from emp e, dept d
where e.dept_id=d.id;
select * from v_emp_dept;


show tables;
